﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebMotel.print
{
    public partial class printCaixaRelatorio : frmRelatorioCaixa
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                foreach (String key in Request.QueryString.AllKeys)
                {
                    if (key == "caixaID")
                    {
                        if (!string.IsNullOrEmpty(Request.QueryString[key]))
                            lblCaixID.Text = Request.QueryString[key];
                        else
                            lblCaixID.Text = "N/D";

                    }
                    else if (key == "dtInicial")
                    {
                        if (!string.IsNullOrEmpty(Request.QueryString[key]))
                            lblDtInicial.Text = Request.QueryString[key].Replace("-","/");
                        else
                            lblDtInicial.Text = "N/D";

                    }
                    else if (key == "dtFinal")
                    {
                        if (!string.IsNullOrEmpty(Request.QueryString[key]))
                            lblDtFinal.Text = Request.QueryString[key].Replace("-", "/");
                        else
                            lblDtFinal.Text = "N/D";

                    }
                    else if (key == "usuario")
                    {
                        lblUsuario.Text = Request.QueryString[key];
                    }
                    else if (key == "formaPagamento")
                    {
                        lblFormaPagamento.Text = Request.QueryString[key];
                    }
                }

                if (Session["relatorio"] != null)
                {
                    List<temp> objs = ((List<temp>)Session["relatorio"]).ToList();
                    rptListagem.DataSource = objs;
                    rptListagem.DataBind();
                }

                String s = "<script language='javascript'> window.print(); </script>";
                Page.RegisterClientScriptBlock("Print", s);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}